package com.yitao.cms.controller.user.appUser;


import com.skipper.base.bean.DataOutput;
import com.skipper.base.bean.PagedInput;
import com.skipper.base.bean.PagedOutput;
import com.yitao.cms.service.shopInfo.CmsShopUserGradeService;
import com.yitao.cms.vo.CategoryVo;
import com.yitao.cms.vo.shop.ShopGradeInfoVo;
import com.yitao.cms.vo.shop.ShopUserGradeListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping(value = "/cms/user/grade", produces = {"application/json"})
@Api(description = "用户等级相关接口", tags = {"cms-user-grade"})
public class UserGradeController {

    @Autowired
    private CmsShopUserGradeService cmsShopUserGradeService;

    /**
     * 列表
     */
    @ApiOperation("店铺交易用户")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public PagedOutput<ShopUserGradeListVo> getShopUserList(@ApiParam(value = "用户ID 纯数字  请勿提交字符", required = false) @RequestParam(value = "userId", required = false) Long userId,
                                                            @ApiParam(value = "昵称", required = false) @RequestParam(value = "userName", required = false) String userName,
                                                            @ApiParam(value = "手机号", required = false) @RequestParam(value = "phone", required = false) String phone,
                                                            @ApiParam(value = "升级时间开始时间", required = false) @RequestParam(value = "updateStaDate", required = false) String updateStaDate,
                                                            @ApiParam(value = "升级时间结束时间", required = false) @RequestParam(value = "updateEndDate", required = false) String updateEndDate,
                                                            @ApiParam(value = "身份等级", required = false) @RequestParam(value = "idx", required = false) Integer idx,
                                                            @ApiParam(value = "注册时间开始时间", required = false) @RequestParam(value = "loginStaDate", required = false) String loginStaDate,
                                                            @ApiParam(value = "注册时间结束时间", required = false) @RequestParam(value = "loginEndDate", required = false) String loginEndDate,
                                                            @ApiParam(value = "分页参数，表示当前页", required = true, defaultValue = "1") @RequestParam(value = "pageNo", required = true) Integer pageNo,
                                                            @ApiParam(value = "分页参数，表示每页显示多少条记录", required = true, defaultValue = "10") @RequestParam(value = "pageSize", required = true) Integer pageSize) {

        return cmsShopUserGradeService.getShopUserList(userId, userName, phone, updateStaDate, updateEndDate, idx, loginStaDate, loginEndDate, new PagedInput(pageSize, pageNo));
    }

    /**
     * 修改用户等级
     */
    @ApiOperation("修改用户等级")
    @RequestMapping(value = "/updateUserGrade", method = RequestMethod.POST)
    public DataOutput updateUserGrade(
            @ApiParam(value = "id") @RequestParam(value = "id", required = false) Long id,
            @ApiParam(value = "idx") @RequestParam(value = "idx", required = false) Integer idx) {
        return cmsShopUserGradeService.updateUserGrade(id, idx);
    }

    /**
     * 开启会员设置
     */
    @ApiOperation("设置会员信息")
    @RequestMapping(value = "/addOrUpdateGradeInfo", method = RequestMethod.POST)
    public DataOutput<ShopGradeInfoVo> addOrUpdateGradeInfo(@RequestBody ShopGradeInfoVo shopGradeInfoVo) {
        return cmsShopUserGradeService.addOrUpdateGradeInfo(shopGradeInfoVo);
    }

    /**
     * 开始或者暂停会员
     */
    @ApiOperation("开始或者暂停会员")
    @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
    public DataOutput updateStatus(@ApiParam(value = "id") @RequestParam(value = "id", required = false) Long id) {
        return cmsShopUserGradeService.updateStatus(id);
    }

    /**
     * 获取详情
     */
    @ApiOperation("获取详情")
    @RequestMapping(value = "/getGradeInfo", method = RequestMethod.POST)
    public DataOutput<ShopGradeInfoVo> getGradeInfo() {
        return cmsShopUserGradeService.getGradeInfo();
    }

    /**
     * 获取 身份等级 下拉
     */
    @ApiOperation("获取 身份等级||修改用户等级身份下拉")
    @RequestMapping(value = "/idxEnum", method = RequestMethod.POST)
    public DataOutput<List<CategoryVo>> getIdxEnum(@ApiParam(value = "传入ID 返回的是 修改用户等级身份 里面的下拉框  不传入ID 是列表搜索的下拉框") @RequestParam(value = "id", required = false) Long id) {
        return cmsShopUserGradeService.getIdxEnum(id);
    }
}
